package net.kazed.nextaction.database.serialize;

import java.util.HashMap;
import java.util.Map;

import org.xml.sax.Attributes;

public abstract class AbstractElementHandler implements ElementHandler {
    
    private Map<String, ElementHandler> elementHandlers;
    
    public AbstractElementHandler() {
        super();
        this.elementHandlers = new HashMap<String, ElementHandler>();
    }

    public AbstractElementHandler(Map<String, ElementHandler> elementHandlers) {
        super();
        this.elementHandlers = elementHandlers;
    }
    
    public void addElementHandler(String name, ElementHandler elementHandler) {
        elementHandlers.put(name, elementHandler);
    }

    @Override
    public void startElement(String name, Attributes attributes,
            ParserState state) {
    }
    
    @Override
    public void characters(String text, ParserState state) {
    }

    @Override
    public void endElement(String name, ParserState state) {
    }

    @Override
    public ElementHandler getElementHandler(String elementName) {
        ElementHandler handler = elementHandlers.get(elementName);
        return handler;
    }
    
    @Override
    public boolean isValueEncoded() {
        return false;
    }
}
